
#include <mutex>
#include <iostream>
#include <cstdlib>
#include <stdlib.h>

#include <unordered_map>
using namespace std;
void raytrace(int x0, int y0, int x1, int y1)
{
    int dx = abs(x1 - x0);
    int dy = abs(y1 - y0);

    int pt_x = x0;
    int pt_y = y0;
    int n = 1 + dx + dy;
    int x_inc = (x1 > x0) ? 1 : -1;
    int y_inc = (y1 > y0) ? 1 : -1;
    int error = dx - dy; //
    dx *= 2;
    dy *= 2;
        
    for (; n > 0; --n)
    {
        //cells.push_back(pt);

        if (error > 0)
        {
            pt_x += x_inc;
            error -= dy;

            std::cout << "pt_x:" << pt_x << "  pt_y:" << pt_y << std::endl;
            std::cout << "error: " << error << std::endl;
        }
        else
        {
            pt_y += y_inc;
            error += dx;
            std::cout << "pt_x:" << pt_x << "  pt_y:" << pt_y << std::endl;
            std::cout << "error: " << error << std::endl;
        }
    }
}

int main ()
{

    raytrace(10, 20, 6, 10);
    return 0;
}